import os 
import config
import shutil


images = ['ic_loading_newsapp_110x75','ic_loading_newsapp_225x165','ic_loading_newsapp_480x265','splash','icon']

def remove_pics():
    img_path = os.path.sep.join(['..','res','drawable-hdpi'])
    for item in images:
        fname = os.path.sep.join((img_path, item+'.png'))
        if os.path.exists(fname):
            os.remove(fname)

def remove_bin():
    bin_path = os.path.sep.join(['..','bin'])
    os.removedirs(bin_path)

def set_pics():
    from_path = os.path.sep.join(['..','..','AllThatApps',config.APP_ID])
    to_path = os.path.sep.join(['..','res','drawable-hdpi'])
    for item in images:
        #imgdata = open(os.path.sep.join((from_path, item + '.png'))).read()
        #f = open(os.path.sep.join((to_path, item + '.png')), 'w')
        #f.write(imgdata)
        #f.write(open(os.path.sep.join((from_path, item + '.png'))).read())
        #f.close()
        shutil.copy( os.path.sep.join((from_path, item + '.png')), os.path.sep.join((to_path, item + '.png')))
        
remove_pics()
set_pics()
#remove_bin()
